package com.ch.ms.server.base;

import com.alibaba.fastjson.JSONObject;
import com.ch.ms.server.packet.MaplePacket;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.util.CharsetUtil;

public class MaplePacketEncoder extends MessageToByteEncoder<MaplePacket> {


    @Override
    protected void encode(ChannelHandlerContext ctx, MaplePacket maplePacket, ByteBuf out) throws Exception {
        out.writeCharSequence(JSONObject.toJSONString(maplePacket), CharsetUtil.UTF_8);
    }
}
